<?php
/**
 * Created by PhpStorm.
 * User: g
 * Date: 2018/1/9
 * Time: 15:13
 */

namespace app\index\controller;


use think\Request;

class Systemparamset extends Common
{
    public function emp(){
        if($_POST){

            $data = Request::instance()->post();
            foreach($data as $k=>$v){
                $bool = db('system_param')->where(['t'=>0,'k'=>$k])->count();
                if($bool==0){
                    db('system_param')->insert([
                        'k'=>$k,
                        'v'=>$v,
                        't'=>0,
                    ]);
                }else{
                    db('system_param')->where(['k'=>$k,'t'=>0])->update([
                        'v'=>$v
                    ]);
                }
            }
            echo json_encode(['success'=>true,'msg'=>'保存成功']);
            die;
        }
        $data = db('system_param')->where('t',0)->select();
        $t = [];
        foreach($data as $k=>$v){
            $t[$v['k']] = $v['v'];
        }
        $this->assign('data',$t);
        return $this->fetch();
    }
}